package com.jus.player.util;

import android.content.Context;

import androidx.core.content.ContextCompat;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.jus.player.R;

public class DialogUtils {

    public interface OnConfirmListener {
        void onConfirm();
    }

    public static void showConfirmDialog(Context context, String title, String message,
                                         final OnConfirmListener listener) {
        showConfirmDialog(context, title, message, listener, false);
    }

    public static void showConfirmDialog(Context context, String title, String message,
                                         final OnConfirmListener listener, boolean cancelable) {
        new MaterialAlertDialogBuilder(context)
                .setTitle(title)
                .setMessage(message)
                .setPositiveButton(android.R.string.yes, (dialog, which) -> {
                    if (listener != null) {
                        listener.onConfirm();
                    }
                })
                .setNegativeButton(android.R.string.no, null)
                //.setIcon(android.R.drawable.ic_dialog_info)
                .setIcon(ContextCompat.getDrawable(context, R.drawable.ic_alert))
                .setCancelable(cancelable)
                //.setBackground(context.getResources().getDrawable(R.color.vip_bg))
                .show();
    }
}
